<template>
  <div class="header-bar">
    <div class="header-left">
      <div class="logo-section">
        <div class="logo-icon">
          <svg width="24" height="19" viewBox="0 0 24 19" fill="none">
            <path d="M12 0L24 19H0L12 0Z" fill="#60A5FA"/>
          </svg>
        </div>
        <h1 class="title">具身智能开放平台</h1>
      </div>
    </div>
    
    <div class="header-right">
      <div class="status-badge">
        <span class="status-dot online">●</span>
        <span class="status-text">系统运行正常</span>
      </div>
      
      <div class="timestamp">{{ currentTime }}</div>
      
      <el-icon class="user-icon"><User /></el-icon>
      <span class="username">管理员</span>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted, onUnmounted } from 'vue'
import { User } from '@element-plus/icons-vue'

const currentTime = ref('')

const updateTime = () => {
  const now = new Date()
  currentTime.value = now.toLocaleString('zh-CN', {
    year: 'numeric',
    month: '2-digit',
    day: '2-digit',
    hour: '2-digit',
    minute: '2-digit',
    second: '2-digit'
  }).replace(/\//g, '/')
}

let timer = null

onMounted(() => {
  updateTime()
  timer = setInterval(updateTime, 1000)
})

onUnmounted(() => {
  if (timer) {
    clearInterval(timer)
  }
})
</script>

<style scoped>
.header-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 50px;
  background: var(--primary-bg);
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0px 4px 6px -1px rgba(0, 0, 0, 0.1), 0px 2px 4px -2px rgba(0, 0, 0, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  z-index: 1000;
}

.header-left {
  display: flex;
  align-items: center;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  width: 24px;
  height: 19px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 24px;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: var(--secondary-bg);
  border-radius: 6px;
}

.status-dot {
  font-size: 16px;
}

.status-dot.online {
  color: var(--success-green);
}

.status-text {
  font-size: 14px;
  color: var(--text-secondary);
}

.timestamp {
  font-size: 14px;
  color: var(--text-secondary);
}

.user-icon {
  font-size: 20px;
  color: var(--text-secondary);
}

.username {
  font-size: 14px;
  color: var(--text-secondary);
}
</style>